package com.kasinf.sample.websocket.controller;

import com.kasinf.framework.common.enums.UserTypeEnum;
import com.kasinf.framework.common.pojo.CommonResult;
import com.kasinf.framework.websocket.core.sender.WebSocketMessageSender;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @Author : Kaiser
 * @Date: 2025/6/24  08:44
 */
@RestController
@RequestMapping("message")
public class MessageController {

    @Resource
    public WebSocketMessageSender messageSender;

    @CrossOrigin(origins = "*")
    @PostMapping("send")
    public CommonResult<Boolean> send(@RequestParam String message){
        messageSender.send(UserTypeEnum.ADMIN.getValue(), "notice-push", message);
        return CommonResult.success(true);
    }
}
